package myzzyl.controller;



import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import myzzyl.domain.dto.BedDto;
import myzzyl.domain.dto.FloorDto;
import myzzyl.domain.pojo.Bed;
import myzzyl.domain.pojo.Floor;
import myzzyl.domain.vo.BedVo;
import myzzyl.response.BaseResponse;
import myzzyl.service.BedService;
import myzzyl.service.FloorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/bed")
@Tag(name = "床位相关")
@Slf4j
public class BedController {

    @Autowired
    private BedService bedService;

    /**
     * 获取房间下的所有床位
     */
    @GetMapping("/read/room/{id}")
    public BaseResponse<List<BedVo>> getAllByRoomId(@PathVariable Long id) {
        log.info("获取房间下的所有床位：{}", id);
        List<BedVo> bedVoList = bedService.getAllByRoomId(id);
        return BaseResponse.success(bedVoList);
    }

    /**
     * 获取床位详情
     */
    @GetMapping("/read/{id}")
    public BaseResponse<Bed> getInfo(@PathVariable Long id) {
        log.info("获取床位详情:{}", id);
        return BaseResponse.success(bedService.getInfo(id));
    }


    /**
     * 新增床位
     */
    @PostMapping("/create")
    public BaseResponse<Boolean> add(@RequestBody BedDto bedDto) {
        log.info("新增床位:{}", bedDto);
        return BaseResponse.success(bedService.add(bedDto));
    }


    /**
     * 编辑床位
     */
    @PutMapping("/update")
    public BaseResponse<Boolean> edit(@RequestBody BedDto bedDto) {
        log.info("编辑床位:{}", bedDto);
        return BaseResponse.success(bedService.edit(bedDto));
    }

    /**
     * 删除床位
     */
    @DeleteMapping("/delete/{id}")
    public BaseResponse<Boolean> remove(@PathVariable Long id) {
        log.info("删除床位:{}", id);
        return BaseResponse.success(bedService.deleteBedById(id));
    }
}
